package prassein.rsm.service.base;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import prassein.rsm.dao.base.AuditDao;
import prassein.rsm.entity.base.Audit;

@Service
public class AuditManager {
	@Autowired
	private AuditDao auditDao;

	public AuditDao getAuditDao() {
		return auditDao;
	}
	
	public List<Audit> getAudits() {
		return auditDao.getAll();
	}

	public void setAuditDao(AuditDao auditDao) {
		this.auditDao = auditDao;
	}
	
	public void save(Audit audit) {
		auditDao.save(audit);
	}
	
	public void save(String user, String obj, String option) {
		Audit audit = new Audit();
		audit.setUser(user);
		audit.setObject(obj);
		audit.setMotion(option);
		audit.setTime(new Date().toLocaleString());
		auditDao.save(audit);
	}
}
